import { BasicColumn } from "@/components/Table";


export const tableColumns: BasicColumn[] = [
  {
    title: '用户名称',
    dataIndex: 'username'
  },
  {
    title: '用户昵称',
    dataIndex: 'nickname'
  },
  {
    title: '用户手机号',
    dataIndex: 'phone',
    customRender: ({ record }) => {
      const phoneNum = record.phone || '';
      return phoneNum ? (phoneNum.substr(0, 3) + '...' + phoneNum.substr(phoneNum.length-3, phoneNum.length)) : '--'
    }
  },
  {
    title: '店铺',
    dataIndex: 'store',
    customRender: ({ record }) => {
      const store = record.store;
      return store ? store.name : '--'
    }
  },
  {
    title: '用户头像',
    dataIndex: 'avatar',
    slots: {
      customRender: 'avatar' 
    }
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 280,
    fixed: 'right',
    slots: {
      customRender: 'action' 
    }
  }
]

export const AddUserRules = {
  username: [
    { required: true, message: '请输入用户名', trigger: 'blur' },
    { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
  ],
  nickname: [
    { min: 2, max: 10, message: '长度在 3 到 10 个字符'}
  ],
  password: [
    { required: true, message: '请输入密码' },
    // { min: 6, max: 15, message: '长度在 6 到 15 个字符'}
  ]
}